home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / DCLAP 4j / DApp / MyApp.cpp < prev    next >
Encoding:
Text File  |  1995-12-17  |  33.0 KB  |  1,221 lines  |  [TEXT/R*ch]

  1. // MyApp.cp
  2. // d.g.gilbert -- test application using DClAp library
  3. //
  4.  
  5.  
  6. #include <DClap.h>
  7. #include "DChildApp.h"
  8. #include <DRich.h>
  9.  
  10. // test what parts of rich text processors are dragging
  11. //#include "Profiler.h"
  12.  
  13.  
  14.  
  15. class DMyApp : public DRichApplication
  16. {
  17. public:
  18.     enum myapptasks { 
  19.         kSpecial1=1001, kSpecial2,
  20.         kControlsDemo, kListboxDemo, kDialogTextDemo, kIconButtonsDemo,
  21.         kTextDocDemo, kSlateWindow,kAutoWindow,
  22.         kMGroup1, kMGroup2, kMGroup3,
  23.         kDocWindow, kFixedWindow, kFrozenWindow, kRoundWindow, kAlertWindow,
  24.         kFloatingWindow, kShadowWindow, kPlainWindow };
  25.     void IMyApp(void);     
  26.     virtual ~DMyApp();
  27.     
  28.     virtual void ControlsDemo(void);     
  29.     virtual void ListboxDemo(void);     
  30.     virtual void DialogTextDemo(void);     
  31.     virtual void IconButtonsDemo(void);     
  32.     virtual void TextDocDemo(char* filename = NULL);    
  33.     virtual void SlateWindow(void);    
  34.     virtual void AutoPanelWindow(void);    
  35.  
  36.     virtual void SetUpMenus(void);    // override
  37.     virtual    Boolean IsMyAction(DTaskMaster* action); //override
  38.     virtual    void UpdateMenus(void); // override
  39.  
  40. };
  41.  
  42.  
  43.  
  44. // DIE 16bit SCUM -- damn 16bit os/compiler can't handle char const '1234'
  45. // which i used through for very hande ID values
  46.  
  47. enum myappIDvalues {
  48. cMnuS = 2000, cMgpS,cClux,cRada,cRadb,cRadc,cSlaW,cSlat,cClu4,
  49. cLaunchApp,
  50. cRad1,cRad2,cRad3,cDlg1,cClu1,cPgp1,cClu2,cEdt1,cEdt2,cEdt3,
  51. cClu3,cPBut,cDBut,cChkb,cClu5,cSwbx,cMnuW,cGVue,cIcoB,cTDPl,
  52. cSwb2,cClu6,cPopl,cDlgL,cclu0,cPgp2,cclu1,cLiBx,cDlgT,
  53. cclu2,cAPWn,cETBx,cDlg2,cTdoc,cWinD,cWinF,cWinZ
  54. };
  55.  
  56.  
  57. extern "C" short Main(void)
  58. {
  59.   DMyApp* myapp = new DMyApp();
  60.   myapp->IMyApp();
  61.   myapp->Run();
  62.   delete myapp; 
  63.   return 0;
  64. }
  65.  
  66.  
  67. void DMyApp::IMyApp(void)
  68. {
  69.     IApplication();
  70.     //gIconList->Read("icons");
  71.     //fRTFsetup= new DRTFsetup(); // depends on gFileManager created in IApplication
  72. }     
  73.  
  74.  
  75. DMyApp::~DMyApp()
  76. {
  77.     //delete fRTFsetup;
  78. }
  79.  
  80. #if 0
  81. static unsigned short pictureIcon[] = {
  82.  2215, 0, 32, 32, 64,
  83.  0x1fff, 0xfc00, 0x1000,  0x600, 0x13a0,  0x500, 0x13a0,  0x480,
  84.  0x13a8, 0x2440, 0x13a0,  0x420, 0x13a0, 0xe7f0, 0x13a1, 0x1010,
  85.  0x13a2,  0x810, 0x13a2,  0x810, 0x13aa,  0x890, 0x13a1, 0x1010,
  86.  0x13e0, 0xe010, 0x1220,   0x10, 0x1220,   0x10, 0x1220,   0x10,
  87.  0x122b, 0xfe90, 0x1222,  0x210, 0x11c2,  0x210, 0x1322, 0x1fd0,
  88.  0x1322, 0x1050, 0x1212, 0x1050, 0x121b, 0xf250, 0x1210, 0x1050,
  89.  0x1230, 0x1050, 0x1120, 0x1fd0, 0x11a0,   0x10, 0x10e0,   0x10,
  90.  0x1230, 0x2090, 0x1000,   0x10, 0x1000,   0x10, 0x1fff, 0xfff0,
  91.   0,0,0,0,0,0 
  92. };
  93.  
  94. static DIcon gPictureIcon( (IconStore*) pictureIcon);
  95. #endif
  96.  
  97.  
  98. void DMyApp::SetUpMenus(void)
  99. {
  100.     DApplication::SetUpMenus();
  101.  
  102.     DMenu* sMenu = NewMenu(cMnuS, "Test");
  103.  
  104.     sMenu->AddItem( DMyApp::kSpecial1, "Check 1", true);
  105.     sMenu->AddItem( DMyApp::kSpecial2, "Check 2", true);
  106.     DMenuChoiceGroup* cGroup= new DMenuChoiceGroup(cMgpS, sMenu);
  107.     cGroup->AddItem( DMyApp::kMGroup1, "GroupItem 1");
  108.     cGroup->AddItem( DMyApp::kMGroup2, "GroupItem 2");
  109.     cGroup->AddItem( DMyApp::kMGroup3, "GroupItem 3");
  110.     sMenu->AddSeparator();                                
  111.     sMenu->AddItem( DMyApp::kControlsDemo, "Controls demo");
  112.     sMenu->AddItem( DMyApp::kListboxDemo, "Listbox demo");
  113.     sMenu->AddItem( DMyApp::kDialogTextDemo, "DialogText & LaunchApp demo");
  114.     sMenu->AddItem( DMyApp::kIconButtonsDemo, "IconButtons demo");
  115.     sMenu->AddItem( DMyApp::kTextDocDemo, "TextDoc demo");
  116.  
  117. #if THIS_IS_BUGGY
  118.     sMenu->AddItem( DMyApp::kSlateWindow, "Slate test");
  119.     sMenu->AddItem( DMyApp::kAutoWindow, "AutoPanel test");
  120. #endif
  121.     sMenu->suicide(1);
  122.  
  123. #if 1
  124.     // need a GetMenu(cMnuW), & menu::RemoveItem(...)
  125.     DMenu* wMenu= (DMenu*) gViewCentral->GetView(cMnuW);
  126.     if (!wMenu) wMenu= sMenu;
  127.     wMenu->AddSeparator();                                
  128.     wMenu->AddItem( DMyApp::kDocWindow, "Doc window");
  129.     wMenu->AddItem( DMyApp::kFixedWindow, "Fixed window");
  130.     wMenu->AddItem( DMyApp::kFrozenWindow, "Frozen window");
  131.     wMenu->AddItem( DMyApp::kRoundWindow, "Round window");
  132.     wMenu->AddItem( DMyApp::kAlertWindow, "Alert window");
  133.     wMenu->AddItem( DMyApp::kFloatingWindow, "Floating window");
  134.     wMenu->AddItem( DMyApp::kShadowWindow, "Shadow window");
  135.     wMenu->AddItem( DMyApp::kPlainWindow, "Plain window");
  136.     wMenu->suicide(1);
  137. #endif    
  138. }
  139.  
  140.  
  141. #if 0
  142. // Cut this DMyAutoPanel into two parts:
  143. //    DTableView.cp/.h class -- general Table/Gridview for DClap
  144. //    DGopherView subclass
  145.  
  146. class DMyAutoPanel : public DPanel
  147. {
  148. public:
  149.         DGopherList*     fItems;
  150.         short        fMaxRows, fMaxCols;
  151.         short        fItemHeight, fItemWidth;
  152.         short        fTop, fLeft, fSelectedItem;
  153.         short        *fWidths, *fHeights;
  154.         Boolean    fHasVbar, fHasHbar;
  155.         Nlm_RecT    fRect;
  156.         
  157.         DMyAutoPanel(long id, DView* itsSuperior, DGopherList* itsItems,
  158.                     short pixwidth, short pixheight, short itemwidth, short itemheight):
  159.             DPanel( id, itsSuperior, pixwidth, pixheight, DPanel::autonomous),
  160.             fItems(itsItems), fItemWidth(itemwidth), fItemHeight(itemheight),
  161.             fTop(0), fLeft(0), fMaxRows(1), fMaxCols(1), fSelectedItem(-1),
  162.             fWidths(NULL), fHeights(NULL)
  163.         {
  164.             Nlm_BaR sb = Nlm_GetSlateVScrollBar ((Nlm_SlatE) GetNlmObject());
  165.           fHasVbar= (sb != NULL);
  166.           sb = Nlm_GetSlateHScrollBar ((Nlm_SlatE) GetNlmObject());
  167.           fHasHbar= (sb != NULL);
  168.           FindLocation();
  169.         }
  170.         
  171.         void SetGridSize( short rows, short cols)
  172.         {
  173.             short i;
  174.             if (fWidths && rows!=fMaxRows) {
  175.                 fWidths= (short*)MemMore( fWidths, rows * sizeof(short));
  176.                 for (i= fMaxRows; i<rows; i++) fWidths[i]= fItemWidth;
  177.                 }
  178.             if (fHeights && cols!=fMaxCols) {
  179.                 fHeights= (short*)MemMore( fHeights, cols * sizeof(short));
  180.                 for (i= fMaxCols; i<cols; i++) fHeights[i]= fItemHeight;
  181.                 }
  182.             fMaxRows= rows; 
  183.             fMaxCols= cols;
  184.         }
  185.         
  186.         void SetItemWidth(short atcol, short ncols, short itemwidth)
  187.         {
  188.             short i;
  189.             if (!fWidths && ncols < fMaxCols) {
  190.                 // make fWidths
  191.                 fWidths= (short*)MemNew( fMaxCols*sizeof(short));
  192.                 for (i= 0; i<fMaxCols; i++) fWidths[i]= fItemWidth;
  193.                 }
  194.             short ncol= Min(fMaxCols, atcol+ncols);
  195.             for (i= atcol; i<ncol; i++) fWidths[i]= itemwidth;
  196.         }
  197.         
  198.         
  199.         void FindLocation()
  200.         {
  201.             this->GetPosition(fRect); // ?? this isn't changing except w/ resize ??
  202.           if (fHasVbar) fRect.right  -= Nlm_vScrollBarWidth;
  203.           if (fHasHbar) fRect.bottom -= Nlm_hScrollBarHeight;
  204.             Nlm_InsetRect( &fRect, 2, 2);
  205.         }
  206.         
  207.         virtual void Resize(DView* superview, Nlm_PoinT sizechange)
  208.         {
  209.                 // !! need this fRect change to deal w/ Resize() update event, 
  210.                 // which isn't put in a nice event queue, but is done immediately !!
  211.             fRect.right  += sizechange.x;
  212.             fRect.bottom += sizechange.y;
  213.             DPanel::Resize(superview, sizechange);
  214.             FindLocation();
  215.         }
  216.  
  217.         virtual void Scroll(Boolean vertical, DView* scrollee, short newval, short oldval)
  218.         {
  219.             Nlm_RecT    r = fRect;
  220.             short delta;
  221.             short diff= newval-oldval;
  222.             if (vertical) {
  223.                 fTop += diff;
  224.                 delta= diff * fItemHeight;
  225.                 Nlm_ScrollRect (&r, 0, -delta);
  226.                 if (diff<0) r.bottom= r.top - delta;
  227.                 else r.top= r.bottom - delta;
  228.                 }
  229.             else {
  230.                 if (fWidths) {
  231.                     //short i, n;
  232.                     //delta= 0;
  233.                     //if (diff<0) n= -diff; else n=diff;
  234.                   //for ( i=0 ; n>0; i++,n--) delta += fWidths[fLeft+i];
  235.                     fLeft += diff;
  236.                     }
  237.                 else {
  238.                     fLeft += diff;
  239.                     delta= diff * fItemWidth;
  240.                     Nlm_ScrollRect (&r, -delta, 0);
  241.                     if (diff<0) r.right= r.left - delta;
  242.                     else r.left= r.right - delta;
  243.                     }
  244.                 }
  245.             Nlm_InvalRect(&r);
  246.             }
  247.             
  248.         virtual void GetRowRect( short row, Nlm_RecT& r)
  249.         {
  250.             r= fRect;
  251.             r.top += (row-fTop) * fItemHeight;
  252.             r.bottom = r.top + fItemHeight;
  253.         }
  254.  
  255.         virtual void GetColRect( short col, Nlm_RecT& r)
  256.         {
  257.             short i;
  258.             r= fRect;
  259.             if (fWidths) {
  260.                 for (i= fLeft; i<col; i++) r.left += fWidths[i];
  261.                 r.right= r.left + fWidths[col];
  262.                 }
  263.             else {
  264.                 r.left += (col-fLeft) * fItemWidth;
  265.                 r.right = r.left + fItemWidth;
  266.                 }
  267.         }
  268.  
  269.         virtual void GetCellRect( short row, short col, Nlm_RecT& r)
  270.         {
  271.             short i;
  272.             r= fRect;
  273.             if (fWidths) {
  274.                 for (i= fLeft; i<col; i++) r.left += fWidths[i];
  275.                 r.right= r.left + fWidths[col];
  276.                 }
  277.             else {
  278.                 r.left += (col-fLeft) * fItemWidth;
  279.                 r.right = r.left + fItemWidth;
  280.                 }
  281.             r.top += (row-fTop) * fItemHeight;
  282.             r.bottom = r.top + fItemHeight;
  283.         }
  284.             
  285.         virtual void ClickAt(short row, short col)
  286.         {
  287.             if (Nlm_dblClick) {
  288.                 DGopher* ag= fItems->GopherAt(row); 
  289.                 Message(MSG_OK, "Click on '%s'", (char*)ag->GetName());
  290.                 }
  291.             else {
  292.                 Nlm_RecT    r;
  293.                 if (fSelectedItem>=0) {
  294.                     GetRowRect( fSelectedItem, r);
  295.                     Nlm_InvertRect( &r); //Nlm_InvalRect( &r);
  296.                     }
  297.                 if (fSelectedItem == row) fSelectedItem= -1;
  298.                 else fSelectedItem = row;
  299.                 if (fSelectedItem>=0) {
  300.                     GetRowRect( fSelectedItem, r);
  301.                     Nlm_InvertRect( &r);  
  302.                     }
  303.                 }
  304.         }
  305.             
  306.         virtual void Click(Nlm_PoinT mouse)
  307.             {
  308.             // cellview::clickat(row, col);
  309.             short row, col;
  310.             row= fTop  + (mouse.y - fRect.top)  / fItemHeight;
  311.             if (fWidths) {
  312.                 short xcol= fRect.left;
  313.                 col= fLeft;
  314.                 while (xcol < mouse.x) {
  315.                     xcol += fWidths[col];
  316.                     col++;
  317.                     }
  318.                 }
  319.             else
  320.                 col= fLeft + (mouse.x - fRect.left) / fItemWidth;
  321.             if (row >=0 && row < fMaxRows && col >= 0 && col < fMaxCols) 
  322.                 ClickAt( row, col);
  323.             }
  324.  
  325.         virtual void DrawCell(Nlm_RecT r, short row, short col)
  326.         {
  327.             DGopher* ag= fItems->GopherAt(row); 
  328.             switch (col) {
  329.                 case 0: //ag->DrawIcon(r,1); break;
  330.                     {
  331.                     DIcon *ic= *((DIcon**)gIconList->At(1)); 
  332.                     if (ic) ic->Draw(r);
  333.                     }
  334.                     break;
  335.                 case 1: ag->DrawTitle(r); break;
  336.                 case 2: ag->DrawPath(r); break;
  337.                 case 3: ag->DrawHost(r); break;
  338.                 case 4: ag->DrawPort(r); break;
  339.                 case 5: ag->DrawPlus(r); break;
  340.                 case 6: ag->DrawKind(r); break;
  341.                 case 7: ag->DrawDate(r); break;
  342.                 case 8: ag->DrawSize(r); break;
  343.                 case 9: ag->DrawAdmin(r); break;
  344.                 }
  345.         }
  346.             
  347.         virtual void DrawRow(Nlm_RecT r, short row)
  348.         {
  349.             short col = fLeft; 
  350.             if (fWidths) r.right= r.left + fWidths[col];
  351.             else r.right= r.left + fItemWidth;
  352.             while (r.left < fRect.right && col < fMaxCols) {
  353.             if (Nlm_RectInRgn (&r, Nlm_updateRgn))  
  354.                 DrawCell( r, row, col);
  355.                 if (fWidths) {
  356.                     Nlm_OffsetRect( &r, fWidths[col], 0);
  357.                     r.right= r.left + fWidths[col+1];
  358.                     }
  359.                 else
  360.                     Nlm_OffsetRect( &r, fItemWidth, 0);
  361.                 col++;
  362.                 }
  363.         }
  364.         
  365.         virtual void Draw()
  366.         {
  367.             Nlm_RecT    r = fRect;
  368.             short         row = fTop; 
  369.             r.bottom= r.top + fItemHeight;
  370.             Nlm_SelectFont(Nlm_programFont); //fFont);
  371.             while (r.top < fRect.bottom && row < fMaxRows) {
  372.             if (Nlm_RectInRgn (&r, Nlm_updateRgn)) {  
  373.                 DrawRow( r, row);
  374.                 if (row == fSelectedItem) Nlm_InvertRect( &r);
  375.                 }
  376.                 Nlm_OffsetRect( &r, 0, fItemHeight);
  377.                 row++;
  378.                 }
  379.         }
  380.         
  381. };
  382.  
  383. #endif
  384.  
  385.  
  386.  
  387.  
  388. // from vibincld.h
  389. extern "C" Nlm_GphPrcsPtr Nlm_GetClassPtr PROTO((Nlm_GraphiC a));
  390.  
  391. #if 0
  392.  
  393. extern "C" void Nlm_SetVisible PROTO((Nlm_GraphiC a, Nlm_Boolean visibl));
  394.     // ?? make this a DView:: method
  395. void SetVisible(DView* aview, Boolean turnon)
  396. {
  397.     Nlm_SetVisible( (Nlm_GraphiC)aview->GetNlmObject(), turnon);
  398.     if (aview->fSubordinates) {
  399.         long i, n= aview->fSubordinates->GetSize();
  400.         for (i= 0; i<n; i++) {
  401.             DView* subord= (DView*)aview->fSubordinates->At(i);
  402.             if (subord) SetVisible(subord, turnon); 
  403.             }        
  404.         }
  405. }
  406.  
  407. #endif
  408.  
  409.  
  410.  
  411.  
  412. class DControlTable : public DTableView
  413. {
  414. public:
  415.     DList* fItems;
  416.     //DWindow* fDummyWin;
  417.     
  418.     DControlTable(long id, DView* itsSuperior, DList* itsItems,
  419.                 short pixwidth, short pixheight, 
  420.                 short nrows, short ncols,
  421.                 short itemwidth, short itemheight):
  422.     DTableView( id, itsSuperior, pixwidth, pixheight, nrows, ncols, itemwidth, itemheight),
  423.     //fDummyWin(NULL),
  424.     fItems(itsItems)
  425.     {}
  426.  
  427.     //virtual void Drag(Nlm_PoinT mouse);
  428.     //virtual void Hold(Nlm_PoinT mouse);
  429.     //virtual void Release(Nlm_PoinT mouse);
  430.     
  431.     virtual void DoubleClickAt(short row, short col)
  432.     {
  433.         DCluster* ac= (DCluster*) fItems->At(row); 
  434.         Message(MSG_OK, "Click on '%s'", (char*)ac->GetTitle());
  435.     }
  436.  
  437.     virtual void Click(Nlm_PoinT mouse)
  438.     {
  439.         short row, col;
  440.         PointToCell( mouse, row, col);
  441.         DCluster* ac= (DCluster*) fItems->At(row); 
  442. #ifdef WIN_MAC
  443.       Nlm_GphPrcsPtr  classPtr;
  444.       Nlm_BGphPnt            groupclick;
  445.         Nlm_GraphiC g= (Nlm_GraphiC)ac->GetNlmObject();
  446.          classPtr = Nlm_GetClassPtr( g);
  447.          groupclick= classPtr->click;
  448.         if (groupclick && (*groupclick)(g, mouse)) ;
  449. #endif
  450.     }
  451.     
  452.     virtual void DrawRow(Nlm_RecT r, short row)
  453.     {
  454.         DCluster* ac= (DCluster*) fItems->At(row); 
  455.         if (ac) {
  456. #if 0
  457.             Nlm_InsetRect(&r, 2, 2);
  458.             ac->SetPosition( r);
  459. #endif
  460.             ac->Show();
  461.             }
  462.     }
  463.  
  464.     
  465.     void SetClusterPositions()
  466.     {
  467.         Nlm_RecT r, myrect= GetRect();
  468.         for (short arow= GetTop(); arow< GetMaxRows(); arow++ ) {
  469.             GetRowRect( arow, r);
  470.             if (Nlm_RectInRect( &r, &myrect)) {
  471.                 DCluster* ac= (DCluster*) fItems->At(arow); 
  472.                 if (ac) {
  473.                     Nlm_InsetRect( &r, 2, 2);
  474.                     ac->SetPosition( r);
  475.                     Nlm_ValidRect( &r); // ??
  476.                     }
  477.                 }
  478.             }
  479.     }
  480.     
  481.     void Scroll(Boolean vertical, DView* scrollee, short newval, short oldval)
  482.     {
  483. #if 1
  484.         DTableView::Scroll(vertical, scrollee, newval, oldval);
  485.         this->SetClusterPositions();
  486. #else
  487.         Nlm_RecT    r = fRect;
  488.         short diff= newval-oldval;
  489.         if (vertical) {
  490.             fTop += diff;
  491.             }
  492.         else {
  493.             fLeft += diff;
  494.             }
  495.         this->Select(); // need for motif !
  496.         Nlm_InvalRect(&r);
  497. #endif
  498.     }
  499.     
  500. };
  501.  
  502.  
  503.  
  504. void DMyApp::AutoPanelWindow()
  505. {
  506.     const short kRowHeight=  40;
  507.     const short kRowWidth = 300;
  508.     const short kNumItems =  30;  // pixel maxint enforces smaller num -- rowHeight * num > maxint
  509.     DRadioButton* rb;
  510.     DCluster* cluster;
  511.     Nlm_RecT    arect, brect;
  512.     short    rowHeight = kRowHeight;
  513.     short rowWidth  = kRowWidth;
  514.  
  515.     //DWindow* dummy= new DWindow(cDumb, this, DWindow::fixed, 10, 10, 10, 10, NULL);
  516.         
  517.     DWindow* win= new DWindow(cAPWn, this, DWindow::document, -1, -1, -20, -20, "AutoPanel test");
  518.  
  519.     DList* glist = new DList();
  520.     DControlTable *sl= 
  521.         new DControlTable(cGVue, win, glist, kRowWidth, 250, kNumItems, 1, kRowWidth, kRowHeight);
  522.     sl->SetResize( DView::relsuper, DView::relsuper);
  523.     //sl->fDummyWin= dummy; // testing offscreen redraw
  524.     
  525.     DView* super= sl;
  526.     for (short i= 1; i<=kNumItems; i++) {
  527.         cluster= new DCluster(cClux, super, 100, 50, true, "Radio buttons"); //true==hidden ??
  528.         //cluster->SetPosition( arect); //??
  529.         rb= new DRadioButton(cRada, cluster, "Left");
  530.         rb= new DRadioButton(cRadb, cluster, "Center");
  531.         rb= new DRadioButton(cRadc, cluster, "Right");
  532.         cluster->Hide(); //??
  533.         glist->InsertLast(cluster);
  534.         }
  535.  
  536.     sl->SetClusterPositions();
  537.     
  538.     win->Open();
  539.     win->suicide(1);
  540. }
  541.  
  542.  
  543.  
  544.  
  545. class DMySlatePanel : public DSlatePanel
  546. {
  547. public:
  548.         DCluster* fCluster;
  549.         
  550.         DMySlatePanel(long id, DSlate* itsSuperior, DCluster* itsCluster,
  551.                 short pixwidth, short pixheight):
  552.             DSlatePanel( id, itsSuperior, pixwidth, pixheight),
  553.             fCluster(itsCluster)
  554.             {}
  555.             
  556.         virtual void Click(Nlm_PoinT mouse)
  557.         {
  558.             Message(MSG_OK, "Panel hit is ID #%d", this->Id());
  559.         }
  560.             
  561.         virtual void Draw()
  562.         {
  563.             Nlm_RecT    r;
  564.             char    snum[80];
  565.             short    hoff, voff;
  566.             
  567.             this->GetPosition(r); // this doesn't take into account scroll
  568.  
  569.             this->GetOffset( hoff, voff);
  570.             Nlm_OffsetRect( &r, -hoff, -voff); //<< !! this is needed to deal w/ scroll
  571.             
  572.             Nlm_FrameRect(&r);
  573.             Nlm_InsetRect(&r, 2, 2);
  574.                             
  575.             Nlm_LongToStr( this->Id(), snum, 0, 80);
  576.             Nlm_DrawString( &r, snum, 'c', false);
  577.             
  578.             if (fCluster) {
  579.                 fCluster->SetPosition(r); //?? does this call draw??
  580.                 fCluster->Show();
  581.               //fCluster->Select();     //??
  582.                 //Nlm_ValidRect( &r);     // stop loop?
  583.                 }
  584.         }
  585. };
  586.  
  587.  
  588.  
  589. void DMyApp::SlateWindow()
  590. {
  591.     const short kRowHeight = 50;
  592.     const short kNumItems = 20;
  593.     DMySlatePanel *pan;
  594.     DRadioButton* rb;
  595.     DCluster* cluster;
  596.     Nlm_RecT    arect, brect;
  597.     short    rowHeight, rowWidth;
  598.     DEditText*    et;
  599.     DView*    super;
  600.     
  601.     DWindow* win= new DWindow(cSlaW, this, DWindow::document,-10, -10, -20, -20, "Slate test");
  602.  
  603.     DSlate *sl= new DSlate(cSlat, win, 20/*wid*/, 15/*hgt*/, DSlate::scrolling);
  604.  
  605.     cluster= new DCluster(cClu4, win, 100, 50, false, "Radio1 buttons");
  606.     rb= new DRadioButton(cRad1, cluster, "Left1");
  607.     rb= new DRadioButton(cRad2, cluster, "Center1");
  608.     rb= new DRadioButton(cRad3, cluster, "Right1");
  609.     
  610.     sl->GetPosition( arect);
  611.     cluster->GetPosition( brect);
  612.     rowHeight= brect.bottom - brect.top;
  613.     rowWidth= brect.right - brect.left;
  614.   arect.top += 4;
  615.   arect.left += 4;
  616.      arect.bottom = arect.top + rowHeight;
  617.   arect.right = arect.left + rowWidth;
  618.   Nlm_PoinT zeropt;
  619.   zeropt.x = arect.left;
  620.   zeropt.y = arect.top;
  621.  
  622. #if 0
  623.   Nlm_GphPrcsPtr  classPtr;
  624.   Nlm_GGphGph            slatelink;
  625.   
  626.      classPtr = Nlm_GetClassPtr( (Nlm_GraphiC)sl->GetNlmObject());
  627.      slatelink= classPtr->linkIn;
  628. #endif
  629.  
  630.     for (short i= 0; i<kNumItems; i++) {
  631.  
  632.         pan= new DMySlatePanel( 1001+i, sl, NULL, rowWidth, rowHeight);
  633.         pan->SetPosition( arect);
  634. #if 0
  635.       classPtr = Nlm_GetClassPtr( (Nlm_GraphiC)pan->GetNlmObject());
  636.       classPtr->linkIn= slatelink;
  637. #endif
  638.     
  639.         //super= pan; //<< this makes NO NlmObjects as new cluster fails to find a superior draw object
  640.         super= sl; // this bombs for as yet unknown reasons
  641.         //super= win;  
  642.         
  643.         zeropt.x= arect.left;
  644.         zeropt.y= arect.top;
  645.         super->SetNextPosition(zeropt);
  646.         cluster= new DCluster(cClux, super, 100, 50, false, "Radio buttons");
  647.         //cluster->SetPosition( arect); //??
  648.         pan->fCluster= cluster;
  649.         rb= new DRadioButton(cRada, cluster, "Left");
  650.         rb= new DRadioButton(cRadb, cluster, "Center");
  651.         rb= new DRadioButton(cRadc, cluster, "Right");
  652.         cluster->Hide(); //??
  653.         
  654.         //et= new DEditText(cEdt2, cluster, "Edit this text", 20);
  655.         //win->SetEditText(et);
  656.         //et->SetPosition( arect);
  657.  
  658.         //sl->RegisterRow( arect.top/*position*/, 2+rowHeight, 1/*count*/); 
  659.                                         // ^^ must use pixels, not nums
  660.         
  661.         Nlm_OffsetRect( &arect, 0, 2+rowHeight);
  662.         }
  663.             
  664.     
  665.     //Nlm_BaR sb= Nlm_GetSlateVScrollBar((Nlm_SlatE)sl->GetNlmObject());
  666.     //Nlm_SetRange (sb, 1, 5, 10); << don't need w/ RegisterRow working
  667.  
  668.     win->Open();
  669.     win->suicide(1);
  670. }
  671.  
  672.  
  673. void DMyApp::ControlsDemo()
  674. {
  675.     DCluster* cluster;
  676.     DWindow* win= new DWindow(cDlg1, this,  DWindow::fixed, -10, -10, -50, -20, "Controls Dialog");
  677.  
  678.     cluster= new DCluster(cClu1, win, 200, 16, false, "Prompt");
  679.     DPrompt* pr= new DPrompt(cPgp1, cluster, "This is a prompt item", 0, 0, Nlm_programFont);    
  680.  
  681.     cluster= new DCluster(cClu2, win, 200, 16, false, "EditText");
  682.     DEditText* et;
  683.     et= new DEditText(cEdt1, cluster, "edit this text", 20);
  684.     win->SetEditText(et);
  685.     cluster->NextSubviewBelowLeft();
  686.     
  687.     et= new DEditText(cEdt2, cluster, "No, edit THIS text!", 20);
  688.     win->SetEditText(et);
  689.     cluster->NextSubviewBelowLeft();
  690.     
  691.     et= new DEditText(cEdt3, cluster, "Please edit *this* text?", 20);
  692.     win->SetEditText(et);
  693.     cluster->SetValue(2);
  694.  
  695.     cluster= new DCluster(cClu3, win, 100, 50, false, "Buttons");
  696.     DButton* bb= new DButton(cPBut,cluster, "Plain button");
  697.     DDefaultButton* db= new DDefaultButton(cDBut,cluster, "Default");
  698.     DCheckBox* ck= new DCheckBox(cChkb, cluster, "Check box");
  699.     ck->SetStatus(true);
  700.  
  701.     cluster= new DCluster(cClu4, win, 100, 50, false, "Radio buttons");
  702.     DRadioButton* rb;
  703.     rb= new DRadioButton(cRad1, cluster, "Left");
  704.     rb= new DRadioButton(cRad2, cluster, "Center");
  705.     rb= new DRadioButton(cRad3, cluster, "Right");
  706.     cluster->SetValue(2);
  707.  
  708.     cluster= new DCluster(cClu5, win, 100, 20, false, "Switch box");
  709.     DSwitchBox* sb= new DSwitchBox(cSwbx, cluster, true,  false);
  710.     sb->SetValues(5,15);
  711.     sb= new DSwitchBox(cSwb2, cluster, true,  true);
  712.     sb->SetValues(15,50);
  713.  
  714.     cluster= new DCluster(cClu6, win, 100, 20, false, "Popup list");
  715.     DPopupList* pl= new DPopupList(cPopl, cluster, true);
  716.  
  717.     pl->AddItem("Item 1");
  718.     pl->AddItem("brown shoes");
  719.     pl->AddItem("Shoes for Industry");
  720.     pl->AddItem("Shoes for Defense");
  721.     pl->SetValue(2);
  722.  
  723.     DIconButton* ib = new DIconButton(cIcoB, win, &gPictureIcon);
  724.  
  725.     win->AddOkayCancelButtons();
  726.     win->Open();
  727. }
  728.  
  729.  
  730. void DMyApp::ListboxDemo()
  731. {
  732.     DCluster* cluster;
  733.     DWindow* win= new DWindow(cDlgL, this, DWindow::document, -10, -10, -20, -20, "List Box");
  734.  
  735.     cluster= new DCluster(cclu0, win, 200, 16, false, "Prompt");
  736.     DPrompt* pr= new DPrompt(cPgp2, cluster, "This is a test of list box", 0, 0, Nlm_programFont);
  737.     pr->suicide(1);
  738.     cluster->suicide(1);
  739.  
  740.     cluster= new DCluster(cclu1, win, 100, 26, false, "List box");
  741.     DListBox* lb= new DListBox(cLiBx, cluster, 20, 5, false/*DListBox::kSingleScroll*/);
  742.     lb->StartAppending();
  743.     lb->Append("Item 1");
  744.     lb->Append("brown shoes");
  745.     lb->Append("yellow canaries");
  746.     lb->Append("white as snow");
  747.     lb->Append("foxfire");
  748.     lb->Append("purple sage");
  749.     lb->Append("red roses");
  750.     lb->Append("blue violets");
  751.     lb->Append("green jack-in-the-pulpit");
  752.     lb->Append("Item Last");
  753.     lb->DoneAppending();
  754.     lb->SetValue(1); // doesn't seem active on DListBox display
  755.     lb->SetResize( DView::relsuper, DView::relsuper);
  756.     cluster->SetResize( DView::relsuper, DView::relsuper);
  757.     lb->suicide(1);
  758.     cluster->suicide(1);
  759.  
  760.     win->AddOkayCancelButtons();
  761.     win->Open();
  762.     win->suicide(1);
  763. }
  764.  
  765.  
  766. void DMyApp::DialogTextDemo()
  767. {
  768.     DCluster* cluster;
  769.     DWindow* win= new DWindow(cDlgT, this, DWindow::document, -10, -10, -20, -20, "Dialog Text");
  770.  
  771.     Nlm_FonT itsfont = Nlm_programFont; //Nlm_ParseFont ("Times,12");
  772.                 // ^^ need a font manager object to hide some of this ?
  773.     cluster= new DCluster(cclu2, win, 20, 10, false, "Editable text box");
  774.     DDialogScrollText* dt = new DDialogScrollText(cETBx, cluster,
  775.                                              20, 10, itsfont, true/*kDoWrap*/);
  776.     win->SetEditText(dt); 
  777.     dt->SetResize( DView::relsuper, DView::relsuper);
  778.     cluster->SetResize( DView::relsuper, DView::relsuper);
  779.     dt->suicide(1);
  780.     cluster->suicide(1);
  781.  
  782.     DButton* bb= new DButton( cLaunchApp, win, "Launch app specified in text box");
  783.  
  784.     win->AddOkayCancelButtons();
  785.     win->Open();
  786.     win->suicide(1);
  787. }
  788.  
  789.  
  790.  
  791. class DIconWindow : public DWindow
  792. {
  793. public:
  794.     enum {
  795.         cSaveBut = 3232
  796.         };
  797.  
  798.     DIconList* fIconList;
  799.  
  800.     DIconWindow(long id, DTaskMaster* itsSuperior, DIconList* itsIconList,
  801.             short width = -5, short height = -5, short left = -50, short top = -20, char* title = NULL) :
  802.         DWindow( id, itsSuperior, DWindow::fixed, width, height, left, top, title),
  803.         fIconList(itsIconList)
  804.         {}
  805.             
  806.     virtual ~DIconWindow() 
  807.         { 
  808.             if (fIconList) { fIconList->FreeAllObjects(); delete fIconList; }
  809.         }
  810.  
  811.     Boolean IsMyAction(DTaskMaster* action) 
  812.         {    
  813.             switch(action->Id()) {
  814.                 case cSaveBut:
  815.                     //Message(MSG_OK, "Save button hit");
  816.                     fIconList->WriteAsCode(NULL);
  817.                     return true;
  818.                 default: 
  819.                     return DWindow::IsMyAction(action);
  820.                 }
  821.         }
  822.     
  823. };
  824.  
  825.  
  826. static unsigned short testicons1[] = {
  827.  2215, 0, 32, 32, 64,
  828.  0x1fff, 0xfc00, 0x1000,  0x600, 0x13a0,  0x500, 0x13a0,  0x480,
  829.  0x13a8, 0x2440, 0x13a0,  0x420, 0x13a0, 0xe7f0, 0x13a1, 0x1010,
  830.  0x13a2,  0x810, 0x13a2,  0x810, 0x13aa,  0x890, 0x13a1, 0x1010,
  831.  0x13e0, 0xe010, 0x1220,   0x10, 0x1220,   0x10, 0x1220,   0x10,
  832.  0x122b, 0xfe90, 0x1222,  0x210, 0x11c2,  0x210, 0x1322, 0x1fd0,
  833.  0x1322, 0x1050, 0x1212, 0x1050, 0x121b, 0xf250, 0x1210, 0x1050,
  834.  0x1230, 0x1050, 0x1120, 0x1fd0, 0x11a0,   0x10, 0x10e0,   0x10,
  835.  0x1230, 0x2090, 0x1000,   0x10, 0x1000,   0x10, 0x1fff, 0xfff0 
  836. ,
  837.  1214, 0, 32, 32, 64,
  838.  0x1fff, 0xfc00, 0x1000,  0x600, 0x1000,  0x500, 0x1000,  0x480,
  839.  0x1000,  0x440, 0x1000,  0x420, 0x1000,  0x7f0, 0x1000,   0x10,
  840.  0x1049, 0x2410, 0x10aa, 0xaa10, 0x10aa, 0xaa10, 0x1049, 0x2410,
  841.  0x1000,   0x10, 0x1000,   0x10, 0x1092, 0x9210, 0x10aa, 0xaa10,
  842.  0x10aa, 0xaa10, 0x1092, 0x9210, 0x1000,   0x10, 0x1000,   0x10,
  843.  0x1049, 0x2410, 0x10aa, 0xaa10, 0x10aa, 0xae10, 0x1049, 0x2a10,
  844.  0x1000,   0x10, 0x1000,   0x10, 0x1000,   0x10, 0x1000,   0x10,
  845.  0x1000,   0x10, 0x1000,   0x10, 0x1000,   0x10, 0x1fff, 0xfff0 
  846. ,
  847.     22213, 0, 13, 13, 12,
  848.  0xff00, 0x8180, 0x81c0, 0x9040, 0xa840, 0xa840, 0x9240, 0x8240,
  849.  0x8240, 0x8240, 0x8040, 0xffc0 
  850. ,
  851.     22214, 0, 13, 13, 12,
  852.  0xff00, 0x8180, 0x81c0, 0x8040, 0x8040, 0x8040, 0x8040, 0x8040,
  853.  0x8040, 0x8040, 0x8040, 0xffc0 
  854. ,
  855.  1214, 0, 32, 32, 64,
  856.  0x1fff, 0xfc00, 0x1000,  0x600, 0x1000,  0x500, 0x1000,  0x480,
  857.  0x1000,  0x440, 0x1000,  0x420, 0x1000,  0x7f0, 0x1000,   0x10,
  858.  0x1049, 0x2410, 0x10aa, 0xaa10, 0x10aa, 0xaa10, 0x1049, 0x2410,
  859.  0x1000,   0x10, 0x1000,   0x10, 0x1092, 0x9210, 0x10aa, 0xaa10,
  860.  0x10aa, 0xaa10, 0x1092, 0x9210, 0x1000,   0x10, 0x1000,   0x10,
  861.  0x1049, 0x2410, 0x10aa, 0xaa10, 0x10aa, 0xae10, 0x1049, 0x2a10,
  862.  0x1000,   0x10, 0x1000,   0x10, 0x1000,   0x10, 0x1000,   0x10,
  863.  0x1000,   0x10, 0x1000,   0x10, 0x1000,   0x10, 0x1fff, 0xfff0 
  864. ,
  865.   1215, 0, 32, 32, 64,
  866.  0x1fff, 0xfc00, 0x1000,  0x600, 0x13a0,  0x500, 0x13a0,  0x480,
  867.  0x13a8, 0x2440, 0x13a0,  0x420, 0x13a0, 0xe7f0, 0x13a1, 0x1010,
  868.  0x13a2,  0x810, 0x13a2,  0x810, 0x13aa,  0x890, 0x13a1, 0x1010,
  869.  0x13e0, 0xe010, 0x1220,   0x10, 0x1220,   0x10, 0x1220,   0x10,
  870.  0x122b, 0xfe90, 0x1222,  0x210, 0x11c2,  0x210, 0x1322, 0x1fd0,
  871.  0x1322, 0x1050, 0x1212, 0x1050, 0x121b, 0xf250, 0x1210, 0x1050,
  872.  0x1230, 0x1050, 0x1120, 0x1fd0, 0x11a0,   0x10, 0x10e0,   0x10,
  873.  0x1230, 0x2090, 0x1000,   0x10, 0x1000,   0x10, 0x1fff, 0xfff0
  874. ,
  875.     22214, 0, 13, 13, 12,
  876.  0xff00, 0x8180, 0x81c0, 0x8040, 0x8040, 0x8040, 0x8040, 0x8040,
  877.  0x8040, 0x8040, 0x8040, 0xffc0 
  878. ,
  879.   1215, 0, 32, 32, 64,
  880.  0x1fff, 0xfc00, 0x1000,  0x600, 0x13a0,  0x500, 0x13a0,  0x480,
  881.  0x13a8, 0x2440, 0x13a0,  0x420, 0x13a0, 0xe7f0, 0x13a1, 0x1010,
  882.  0x13a2,  0x810, 0x13a2,  0x810, 0x13aa,  0x890, 0x13a1, 0x1010,
  883.  0x13e0, 0xe010, 0x1220,   0x10, 0x1220,   0x10, 0x1220,   0x10,
  884.  0x122b, 0xfe90, 0x1222,  0x210, 0x11c2,  0x210, 0x1322, 0x1fd0,
  885.  0x1322, 0x1050, 0x1212, 0x1050, 0x121b, 0xf250, 0x1210, 0x1050,
  886.  0x1230, 0x1050, 0x1120, 0x1fd0, 0x11a0,   0x10, 0x10e0,   0x10,
  887.  0x1230, 0x2090, 0x1000,   0x10, 0x1000,   0x10, 0x1fff, 0xfff0
  888. ,
  889.   0,0,0,0,0,0 
  890. };
  891.  
  892.  
  893. void DMyApp::IconButtonsDemo()
  894. {
  895.     DCluster* cluster;
  896.     DWindow* win;
  897.     
  898.     char* prompt = "Please select a file containing icon data (X or Mac format)";
  899.     win= new DWindow(0, this, DWindow::fixed, 500, 30, -1, -1, "Icon file");
  900.     DPrompt* dp= new DPrompt(0, win, prompt);             
  901.     win->Open();
  902.     
  903.     char* filename= (char*)gFileManager->GetInputFileName(".icn","TEXT");
  904.     win->CloseAndFree();
  905.     
  906.     if (filename) {
  907.         DIconList* myIconList= new DIconList();
  908.         myIconList->StoreFromCode(testicons1, 3);
  909.         myIconList->Read(filename);
  910.  
  911.         win= new DIconWindow(cDlg2, this, myIconList, -10, -10, -20, -20, "Icon Buttons");
  912.     
  913.         char title[80];
  914.         StrCpy(title, "Icon buttons from ");
  915.         StrNCat(title, (char*) gFileManager->FilenameFromPath(filename), 80);
  916.         cluster= new DCluster(cclu2, win, 100, 50, false, title);
  917.         short count= Min( 100, myIconList->GetSize());
  918.         for (short ic= 0; ic<count; ic++) {
  919.              if (ic % 10 == 0) cluster->NextSubviewBelowLeft();
  920.              else cluster->NextSubviewToRight();
  921.             DIcon* theIcon= myIconList->IconAt(ic);
  922.             DIconButton* ib = new DIconButton(cIcoB, cluster, theIcon);
  923.             }
  924.         
  925.         DButton* bb= new DButton(DIconWindow::cSaveBut, win, "Save as C code");
  926.         win->AddOkayCancelButtons();
  927.         win->Open();
  928.         }
  929. }
  930.  
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938. void DMyApp::TextDocDemo(char* filename)
  939. {
  940.     if (!filename)
  941.         filename= (char*) gFileManager->GetInputFileName(NULL,NULL);
  942.     if (filename) {
  943.         filename= StrDup(filename);
  944.         char* shortname= (char*)gFileManager->FilenameFromPath(filename);
  945.         gCursor->watch();
  946.         DWindow* win= new DWindow(cTdoc, this, DWindow::document, -1, -1, -10, -10, shortname);
  947.         DRichView* td= new DRichView(cTDPl, win, 490, 300);
  948.         td->SetResize( DView::matchsuper, DView::relsuper);
  949.  
  950. #if __profile__
  951. #  ifdef powerc 
  952. #  define TimeBase PPCTimeBase
  953. #  else
  954. #  define TimeBase microsecondsTimeBase;
  955. #  endif
  956.     if (!ProfilerInit(collectSummary, TimeBase, 2000, 40)) {
  957.  
  958.         td->ShowFile( filename);
  959.  
  960.         ProfilerDump("\pMyApp.prof");
  961.         ProfilerTerm();
  962.         }
  963.     else 
  964. #endif
  965.         td->ShowFile( filename);
  966.             
  967.         win->Open();
  968.         MemFree(filename);
  969.         gCursor->arrow();
  970.         }
  971. }
  972.  
  973.  
  974. #if 0
  975. void DMyApp::TextDocDemo()
  976. {
  977.     // use this as kApp::Open...
  978.     // enable the kApp::SaveAs & kApp::Print for frontwindows having any DDocPanels...
  979.     char* filename= (char*) gFileManager->GetInputFileName(".txt","TEXT");
  980.     if (filename) {
  981.         filename= StrDup(filename);
  982.         char* shortname= (char*)gFileManager->FilenameFromPath(filename);
  983.         gCursor->watch();
  984.         DWindow* win= new DWindow(cTdoc, this, DWindow::document, -1, -1, -10, -10, shortname);
  985.         DTextDocPanel* td= new DTextDocPanel(cTDPl, win, 490, 300);
  986.         td->SetResize( DView::matchsuper, DView::relsuper);
  987.         td->ShowFile(filename);
  988.         td->suicide(1);
  989.         
  990.         //win->AddOkayCancelButtons();
  991.         win->Open();
  992.         win->suicide(1);
  993.         MemFree(filename);
  994.         gCursor->arrow();
  995.         }
  996. }
  997. #endif
  998.  
  999.  
  1000. #ifdef NOT_WIN_MAC
  1001. #include <EPPC.h> /* Apple highlevel events */
  1002. #include <Processes.h>  
  1003.  
  1004. char* long2str( long val)
  1005. {
  1006.     static char buf[4];
  1007.   buf[0]= (val >> 24) & 0xff;
  1008.   buf[1]= (val >> 16) & 0xff;
  1009.   buf[2]= (val >> 8) & 0xff;
  1010.   buf[3]= val & 0xff;
  1011.     return buf;    
  1012. }
  1013.  
  1014. extern ProcessSerialNumber  gChildProcessSN;
  1015. extern "C" void Nlm_PtoCstr (Nlm_CharPtr str); 
  1016.  
  1017. void CheckObits()
  1018. {
  1019. #if 1
  1020.     short err, itry = 0;
  1021.     ProcessInfoRec    info;
  1022.     do {
  1023.       itry++;
  1024.         err= GetProcessInformation( &gChildProcessSN, &info);
  1025.         if (!err) Message( MSG_OK, "Child process %s, time %ld", 
  1026.                             Nlm_PtoCstr( (Nlm_CharPtr)info.processName), info.processActiveTime );
  1027.     } while (err == 0 && itry < 20);
  1028. #else
  1029.     TargetID    sender;
  1030.     unsigned long msgRefcon = 0;
  1031.     EventRecord evt;
  1032.     short err, itry= 0;
  1033.     unsigned long buflen= 511;
  1034.     char* buf= (char*) MemNew(buflen+1);
  1035.     while ( WaitNextEvent( highLevelEventMask, &evt, 4, NULL) || itry<5) {
  1036.         itry++;    
  1037.         err= AcceptHighLevelEvent( &sender, &msgRefcon, buf, &buflen);
  1038.         Message(MSG_OK, "HL Event %s, message %s", 
  1039.                                     long2str(evt.message), long2str(msgRefcon));
  1040.         }
  1041.     MemFree(buf);
  1042. #endif
  1043. }
  1044.  
  1045. #else
  1046.  
  1047. void CheckObits()
  1048. {
  1049.  
  1050. }
  1051.  
  1052. #endif
  1053.  
  1054. Boolean DMyApp::IsMyAction(DTaskMaster* action) 
  1055. {
  1056.     DWindow* win= NULL;
  1057.     
  1058.     switch(action->Id()) {
  1059.         
  1060.                 // some menu item messages
  1061.         case DMyApp::kControlsDemo: this->ControlsDemo(); return true;
  1062.         case DMyApp::kListboxDemo:    this->ListboxDemo(); return true;
  1063.         case DMyApp::kIconButtonsDemo: this->IconButtonsDemo(); return true;
  1064.         case DMyApp::kDialogTextDemo: this->DialogTextDemo(); return true;
  1065.         case DMyApp::kTextDocDemo: this->TextDocDemo(); return true;
  1066.         case DMyApp::kSlateWindow: this->SlateWindow(); return true;
  1067.         case DMyApp::kAutoWindow: this->AutoPanelWindow(); return true;
  1068.         
  1069.                 // some button and control item messages
  1070.         case cPBut:
  1071.             Message(MSG_OK,"Plain button hit");
  1072.             return true;
  1073.     
  1074.         case cDBut:
  1075.             Message(MSG_OK, "Default button hit");
  1076.             return true;
  1077.  
  1078.         case cIcoB:
  1079.             Message(MSG_OK, "Icon button selected");
  1080.             return true;
  1081.  
  1082.         case cLaunchApp: {
  1083.             DButton* but= (DButton*) action; 
  1084.             if ( but && ((win= but->GetWindow()) != NULL) && win->HasEditText()) {
  1085. #if 1
  1086.                 char* app= win->fEditText->GetText();
  1087.                 char* cmdline= StrChr(app,' ');
  1088.                 if (cmdline) *cmdline++= 0;
  1089.                 DChildApp* child= new DChildApp( app, cmdline); 
  1090. #if 0
  1091.                 child->AddFile( DChildFile::kStdout, "Stdout.dclap");
  1092. #endif
  1093.                 if (child->Launch())
  1094.                     Message(MSG_OK, "Launched app %s with '%s'", app, cmdline);
  1095.                 else 
  1096.                     Message(MSG_OK, "Failed to launch %s with '%s'", app, cmdline);
  1097.                 MemFree( app);
  1098. #else
  1099.                 char * app, * cmdline;
  1100.                 //DTempFile* temp = new DTempFile();
  1101.                 DFile* temp = new DFile("temp.out","a");
  1102.                 temp->Close();
  1103.                 app= win->fEditText->GetText();
  1104.                 StrExtendCat( &app, " > ");
  1105.                 StrExtendCat( &app, (char*)temp->GetName());
  1106.                 
  1107.                 cmdline= StrChr(app,' ');
  1108.                 if (cmdline) *cmdline++= 0;
  1109.                 if ( Dgg_LaunchApp( app, cmdline)) 
  1110.                     Message(MSG_OK, "Launched app %s with '%s'", app, cmdline);
  1111.                 else 
  1112.                     Message(MSG_OK, "Failed to launch %s with '%s'", app, cmdline);
  1113.     
  1114.                 // ?? wait for 'obit' appleEvent that child is finished ??
  1115.                 CheckObits();
  1116.                 
  1117.                 TextDocDemo( (char*)temp->GetName());
  1118.                 delete  temp;
  1119.                 MemFree( app);
  1120. #endif
  1121.                 }
  1122.             }
  1123.             return true;
  1124.  
  1125.         case cPopl:
  1126.             {
  1127.             short item = 0;
  1128.             DPopupList* pl= (DPopupList*) action;  
  1129.             if (pl) item= pl->GetValue();
  1130.             Message(MSG_OK, "Popup list item selected is #%d", item);
  1131.             }
  1132.             return true;
  1133.  
  1134.         case cOKAY:
  1135.         case cCANC:
  1136.             {
  1137.             DButton* but= (DButton*) action; 
  1138.             if ( but && ((win= but->GetWindow()) != NULL) ) {
  1139.                 if (action->Id() == cOKAY) {
  1140.                     // do Okay close handling...
  1141.                     }
  1142.                 win->CloseAndFree();
  1143.                 }
  1144.             }
  1145.             return true;
  1146.  
  1147.             // menu grouping item message
  1148.         case cMgpS:
  1149.             {
  1150.             char* prompt = NULL;
  1151.             DMenuChoiceGroup* cGroup= (DMenuChoiceGroup*) action;  
  1152.             switch (cGroup->GetValue()) {
  1153.                 case 1: prompt = "Group item 1 selected"; break;
  1154.                 case 2: prompt = "group item 2 selected -- Hi Ho!"; break;
  1155.                 case 3: prompt = "<<<Group item 3 selected>>>"; break;
  1156.                 default: prompt = "Other group item selected"; break;
  1157.                 }
  1158.             win= new DWindow(0, this, DWindow::fixed, 250, 50, -50, -20, "Menu Group result");
  1159.             DPrompt* dp= new DPrompt(0, win, prompt);
  1160.             dp->suicide(1);
  1161.              win->Open();
  1162.             win->suicide(1);
  1163.             return true;
  1164.             }
  1165.             
  1166.         case DMyApp::kDocWindow:
  1167.             win= new DWindow(0, this, DWindow::document, 200, 100, -50, -20, "Document");
  1168.              win->Open();
  1169.              win->suicide(1);
  1170.             return true;
  1171.         case DMyApp::kFixedWindow:
  1172.             win= new DWindow(0, this, DWindow::fixed, 200, 100, -50, -20, "Fixed");
  1173.              win->Open();
  1174.             win->suicide(1);
  1175.             return true;
  1176.         case DMyApp::kFrozenWindow:
  1177.             win= new DWindow(0, this, DWindow::frozen, 200, 100, -50, -20, "Frozen");
  1178.              win->Open();
  1179.             win->suicide(1);
  1180.             return true;
  1181.         case DMyApp::kRoundWindow:
  1182.             win= new DWindow(0, this, DWindow::round, 200, 100, -50, -20, "Round");
  1183.              win->Open();
  1184.             win->suicide(1);
  1185.             return true;
  1186.         case DMyApp::kAlertWindow:
  1187.             win= new DWindow(0, this, DWindow::alert, 120, 100);
  1188.              win->Open();
  1189.             win->suicide(1);
  1190.             return true;
  1191.         case DMyApp::kFloatingWindow:
  1192.             win= new DWindow(0, this, DWindow::floating, 120, 100);
  1193.              win->Open();
  1194.             win->suicide(1);
  1195.             return true;
  1196.         case DMyApp::kShadowWindow:
  1197.             win= new DWindow(0, this, DWindow::shadow, 120, 100);
  1198.              win->Open();
  1199.             win->suicide(1);
  1200.             return true;
  1201.         case DMyApp::kPlainWindow:
  1202.             win= new DWindow(0, this, DWindow::plain, 120, 100);
  1203.              win->Open();
  1204.             win->suicide(1);
  1205.             return true;
  1206.        
  1207.         default: 
  1208.             return DApplication::IsMyAction(action);
  1209.         }
  1210. }
  1211.  
  1212.  
  1213.  
  1214. void DMyApp::UpdateMenus(void)
  1215. {
  1216.     DApplication::UpdateMenus();
  1217.     
  1218.     //gViewCentral->EnableView(DMyApp::kSpecial1);
  1219.     //gViewCentral->EnableView(DMyApp::kSpecial2);
  1220. }
  1221.